package com.godyao.mall.seckill.controller.admin;

import com.godyao.mall.core.model.ResultMsg;
import com.godyao.mall.seckill.model.SeckillActivity;
import com.godyao.mall.seckill.service.ISeckillService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author godyao
 * @date 2022/4/1
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin")
public class SeckillAdminController {
    private final ISeckillService seckillService;

    @PostMapping(value = "/seckillActivity")
    public ResultMsg save(@RequestBody SeckillActivity seckillActivity) {
        return ResultMsg.resultSuccess(seckillService.save(seckillActivity));
    }

    @PutMapping(value = "/seckillActivity")
    public ResultMsg put(@RequestBody SeckillActivity seckillActivity) {
        return ResultMsg.resultSuccess(seckillService.save(seckillActivity));
    }

    @DeleteMapping(value = "/seckillActivity/{id}")
    public ResultMsg put(@PathVariable Long id) {
        seckillService.del(id);
        return ResultMsg.resultSuccess();
    }
}
